<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>采购计划</title>
</head>
<body>
<script type="text/javascript">
$(function(){
	$("#eos_selectEdite_open").textbox({onClickButton: function(){
		$("#edOfficeSuppl_select").window("open");
		$("#edOfficeSuppl_select").panel("refresh");
	}});
});

function saveEdite(){
	$("#form_edite_equipplanla").form({
		onSubmit: function(param){
			var rows = $("#edite_eplan_Details_tabs").datagrid("getRows");
			for(var i = 0; i < rows.length; i ++){
				param['planDetails[' + i +'].edetailName3'] = rows[i].edetailName3;
				param['planDetails[' + i +'].edetailNum'] = rows[i].edetailNum;
				param['planDetails[' + i +'].edetailUnit'] = rows[i].edetailUnit;
				param['planDetails[' + i +'].edetailType'] = rows[i].edetailType;
			}
			var isValid = $(this).form('validate');
			if (!isValid){
				$.messager.progress('close');	// 如果表单是无效的则隐藏进度条
			}
			return isValid;	// 返回false终止表单提交	
		},
		success: function(v){
			var json = eval("(" + v + ")");
			$.messager.alert("操作提示", 
					json.success ? "操作成功" 
					: ("操作失败，原因为：" + json.reason));
			$("#eplan_edite_detail").window("close");
			$("#equip_plan_list").datagrid("reload");
		}
	});
	$("#form_edite_equipplanla").submit();
	
}
</script>
	<div class="easyui-panel" title="采购计划" 
		border="false" fit="true" >
		<form  id="form_edite_equipplanla" action="edite_equiplan" method="post">
			<table width="100%" border="0" style="padding:6px;">
				<tr>	
					<td width="30%"> 
						<input name="eplan.eplanAuthor" style="width:50%;" class="easyui-textbox" label="制定人" 
						data-options="required:true,validType:'isBlank'" id="edite_eplan_Author"> 
						<input name="eplanId" type="hidden"  id="edite_eplan_Id"> 
					</td>
					<td width="35%">
						<select name="eplan.eplanDept" style="width:50%;" class="easyui-combotree" label="采购科室" id="edite_eplan_Dept"
						data-options="url:'to_QueryAllOffice',panelHeight: 'auto',required:true,validType:'isBlank',valueField:'text'">		
						</select>
					</td>
					<td width="35%">
						<select name="eplan.eplanType" style="width:50%;" class="easyui-combobox" label="采购类型" id="edite_eplan_Type"
						data-options="panelHeight: 'auto',required:true,validType:'isBlank'">
							<option value="批次采购">批次采购</option>
							<option value="补货采购">补货采购</option>
						</select>
					</td>
				</tr>
				<tr>
					<td width="30%"> 
						<input name="eplan.eplanTitle" style="width:80%;" class="easyui-textbox" label="采购计划标题" id="edite_eplan_Title"
						data-options="required:true,validType:'isBlank'"> 
					</td>
					<td width="35%">
						<input name="eplan.eplanDate" style="width:60%;" class="easyui-datebox" label="申请日期" id="edite_eplan_Date"
						data-options="required:true,validType:'isBlank'" >
					</td>	
				</tr>
			</table>
			
			<div class="easyui-tabs" border="false" style="width:100%;">
				<div title="采购计划明细">
					<table>
						<tr>
							<td width="40%"><input id="eos_selectEdite_open" class="easyui-textbox"
								label="设备器材" data-options="buttonText:'选择',width:300"></td>
						</tr>
						<tr>
							<td width="30%"><input id="edite_rdetail_num" class="easyui-numberbox"
								label="数量" data-options="min:0,width:150">
							</td>
							<td width="30%"><input id="edite_rdetail_comp" class="easyui-combobox"
								label="单位" readonly="readonly"
								data-options="panelHeight: 'auto',	
									valueField: 'label',
									textField: 'label',
									width:150">
							</td>
							<td width="30%"><input id="edite_rdetail_type" class="easyui-textbox" readonly="readonly"
								label="类型" data-options="width:250">
							</td>		
						</tr>
					</table>
<script type="text/javascript">
function onclickEditeEquip(x){
	var where = $("#edite_select_where").val();
	if(x=="a"){
		$("#edite_select_eos").datagrid({			
			url:'getEquip_list',
			queryParams: {
				where: where,		
			} 
		});
	}else if(x=="b"){
		$("#edite_select_eos").datagrid({			
			url:'getSupply_list',
			queryParams: {
				where: where,		
			} 
			});
	}else{
		$("#edite_select_eos").datagrid({			
			url:'getOffice_list',
			queryParams: {
				where: where,		
			} 
			});
	}
	$("#edite_select_where").textbox('setValue','');
}

</script>					
					<div id="edOfficeSuppl_select" class="easyui-window" title="选择设备器材"
					data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-add',closed:true,"
					style="width: 810px; height: 400px; padding: 5px;">
						<div id="edite_equip_office_supply">
							<div style="float: left">
								<input id="edite_select_where" class="easyui-textbox"
									style="width: 300px; height: 30px; padding: 10px;"
									data-options="prompt:'输入名称关键字'"> </input>
							</div>
							<!-- <div style="margin-left: 500px">
								<a onclick="onclickYes()" class="easyui-linkbutton"
									iconCls="icon-save">确认</a>
							</div>
 -->
							<div id="edite_cc" class="easyui-layout"
								style="margin-top: 5px; width: 770px; height: 320px;">
								<div data-options="region:'west',split:true"
									style="width: 150px;">
									<div class="easyui-panel" border="false" fit="true"
										style="width: 150px; height: 100%; padding: 10px; background: #fafafa;">
										<ul id="edite_tt" class="easyui-tree">
											<li><span>类型</span>
												<ul>
													<li><span><a href="#"
															onclick="onclickEditeEquip('a')">设备</a></span></li>
													<li><span><a href="#"
															onclick="onclickEditeEquip('b')">耗材</a></span></li>
													<li><span><a href="#"
															onclick="onclickEditeEquip('c')">办公用品</a></span></li>
												</ul></li>
										</ul>
									</div>
								</div>
								<div data-options="region:'center'" border="false"
									style="padding: 5px; background: #eee;">
									<!-- <table id="select_eos" style="width: 97%;height:310px"></table>   -->

									<table class="easyui-datagrid"
										style="width: 97%; height: 310px" id="edite_select_eos"
										data-options="url:'',fitColumns:true,singleSelect:true,pagination:true,rownumbers: true,onDblClickRow:SelectEditeESO">
										<thead>
											<tr>
												<th style="width: 5%"
													data-options="field:'check',checkbox:true"></th>
												<th style="width: 10%" data-options="field:'id'">编码</th>
												<th style="width: 30%" data-options="field:'name'">名称</th>
												<th style="width: 15%" data-options="field:'price'">价格</th>
												<th style="width: 15%" data-options="field:'company'">单位</th>
												<th style="width: 25%" data-options="field:'type'">类型</th>
											</tr>
										</thead>
									</table>
								</div>
							</div>
						</div>
					</div>
					<div>
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="appendEdietSO()">添加一行</a>
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeitEdietSO()">删除一行</a>
					</div>
					<table style="width:100%;" id="edite_eplan_Details_tabs" class="easyui-datagrid" data-options="
						singleSelect: true,
						fitColumns: true, nowrap: false,
						rownumbers: true, 
						border: false,
						onDblClickCell: onClickCell,
						onSelect,onSelect,
						onEndEdit: onEndEdit,
						rownumbers: true,
						pagination:true,						
					">
						<thead>
							<tr>
								<th style="width:40%;" data-options="field:'edetailName3'">采购设备器材名</th>
								<th style="width:15%;" data-options="field:'edetailNum',editor: {type: 'textbox'},">数量</th>
								<th style="width:15%;" data-options="field:'edetailUnit'">单位</th>
								<th style="width:30%;" data-options="field:'edetailType'">类型</th>
							</tr>
						</thead>
						
					</table>
				</div>
			</div>
			<div style="margin: 5px 3px;">
				<a href="#" class="easyui-linkbutton" 
				data-options="onClick:saveEdite" iconCls="icon-save">确认修改</a>
			</div>
		</form>	
	</div>
</body>
</html>